package gang.org.springframework.framework.util;

import com.sun.org.apache.xpath.internal.operations.Bool;

import java.util.Map;

/**
 * @author gang.chen
 * @Date 2022/10/13 12:51
 */
public class GangAntPathMatcher implements GangPathMatcher {


    private volatile Boolean cachePatterns;

    @Override
    public boolean isPattern(String path) {
        if (path == null) {
            return false;
        }
        boolean uriVar = false;
        for (int i = 0; i < path.length(); i++) {
            char c = path.charAt(i);
            if (c == '*' || c == '?') {
                return true;
            }
            if (c == '{') {
                uriVar = true;
                continue;
            }
            if (c == '}' && uriVar) {
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean match(String pattern, String path) {
        return doMath(pattern, path, true, null);
    }

    private boolean doMath(String pattern, String path, boolean fullMatch, Map<String, String> uriTemplateVariables) {

        if (false){

        }

        return true;
    }

    protected String[] tokenizePattern(String pattern){

        String[] tokenized = null;

        Boolean cachePatterns = this.cachePatterns;

        return null;
    }

    protected String[] tokenizePath(String path){
        return null;
    }
}
